<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="Kate, the KDE Advanced Text Editor" />
<title>pidgin.py</title>
</head>
<body>
<pre>
<span style='color: #ff80e0'>import</span><span style='color: #141312'> dbus,gobject,time</span>
<span style='color: #ff80e0'>from</span><span style='color: #141312'> dbus.mainloop.glib </span><span style='color: #ff80e0'>import</span><span style='color: #141312'> DBusGMainLoop</span>

<span style='color: #888786'><i>#DBusGMainLoop(set_as_default=True)</i></span>

<span style='color: #141312'>STATUS_OFFLINE = </span><span style='color: #b08000'>1</span>
<span style='color: #141312'>STATUS_AVAILABLE = </span><span style='color: #b08000'>2</span>
<span style='color: #141312'>STATUS_UNAVAILABLE = </span><span style='color: #b08000'>3</span>
<span style='color: #141312'>STATUS_INVISIBLE = </span><span style='color: #b08000'>4</span>
<span style='color: #141312'>STATUS_AWAY = </span><span style='color: #b08000'>5</span>
<span style='color: #141312'>STATUS_EXTENDED_AWAY = </span><span style='color: #b08000'>6</span>
<span style='color: #141312'>STATUS_MOBILE = </span><span style='color: #b08000'>7</span>
<span style='color: #141312'>STATUS_TUNE = </span><span style='color: #b08000'>8</span>


<span style='color: #141312'><b>def</b> get_session_bus() :</span>
<span style='color: #141312'>  bus = dbus.SessionBus()</span>
<span style='color: #141312'>  <b>return</b> bus</span>

<span style='color: #141312'><b>def</b> get_pidgin_object(</span><span style='color: #0057ae'>object</span><span style='color: #141312'> = </span><span style='color: #006e28'>None</span><span style='color: #141312'>) :</span>
<span style='color: #141312'>  bus = get_session_bus()</span>
<span style='color: #141312'>  </span><span style='color: #0057ae'>object</span><span style='color: #141312'> = bus.get_object(</span><span style='color: #bf0303'>"im.pidgin.purple.PurpleService"</span><span style='color: #141312'>,</span>
<span style='color: #141312'>		</span><span style='color: #bf0303'>"/im/pidgin/purple/PurpleObject"</span><span style='color: #141312'>)</span>
<span style='color: #141312'>  pidgin = dbus.Interface(</span><span style='color: #0057ae'>object</span><span style='color: #141312'>, </span><span style='color: #bf0303'>"im.pidgin.purple.PurpleInterface"</span><span style='color: #141312'>)</span>
<span style='color: #141312'>  <b>return</b> pidgin</span>
<span style='color: #141312'>  </span>

<span style='color: #141312'><b>def</b> set_new_status(pidgin, my_account  , message) :</span>
<span style='color: #141312'>	</span>
<span style='color: #141312'>  saved_status = pidgin.PurpleSavedstatusNew(message, STATUS_UNAVAILABLE)</span>
<span style='color: #141312'>  pidgin.PurpleSavedstatusSetMessage(saved_status, message)</span>
<span style='color: #141312'>  pidgin.PurpleSavedstatusActivateForAccount(saved_status, my_account)</span>
<span style='color: #141312'>  </span><span style='color: #888786'><i>#pidgin.PurpleSavedstatusActivate(saved_status)</i></span>


<span style='color: #141312'><b>def</b> main() :</span>
<span style='color: #141312'>  pidgin = get_pidgin_object()</span>
<span style='color: #141312'>  my_account = pidgin.PurpleAccountsFind(</span><span style='color: #bf0303'>"wearetherock@hotmail.com"</span><span style='color: #141312'>, </span><span style='color: #bf0303'>"prpl-msn"</span><span style='color: #141312'>)</span>

<span style='color: #141312'>  believe = </span><span style='color: #0057ae'>open</span><span style='color: #141312'>(</span><span style='color: #bf0303'>"never_say_die.txt"</span><span style='color: #141312'>, </span><span style='color: #bf0303'>"r"</span><span style='color: #141312'>)</span>
<span style='color: #141312'>  lines = believe.readlines()</span>
<span style='color: #141312'>  believe.close()</span>

<span style='color: #141312'>  <b>while</b> </span><span style='color: #006e28'>True</span><span style='color: #141312'> :</span>
<span style='color: #141312'>	<b>for</b> line in lines :</span>
<span style='color: #141312'>	  </span>
<span style='color: #141312'>	  message = line.rstrip().strip()</span>
<span style='color: #141312'>	  <b>if</b> message != </span><span style='color: #bf0303'>''</span><span style='color: #141312'> :</span>
<span style='color: #141312'>		set_new_status(pidgin, my_account, message)</span>
<span style='color: #141312'>		<b>print</b> message</span>
<span style='color: #141312'>		</span>
<span style='color: #141312'>	  time.sleep(</span><span style='color: #b08000'>5</span><span style='color: #141312'>)</span>
<span style='color: #141312'>	  pidgin.PurpleSavedstatusDelete(message)</span>
<span style='color: #141312'>	</span>
<span style='color: #141312'><b>if</b> </span><span style='color: #0057ae'>__name__</span><span style='color: #141312'> == </span><span style='color: #bf0303'>"__main__"</span><span style='color: #141312'> :</span>
<span style='color: #141312'>  main()</span>
<span style='color: #141312'>  </span>
<span style='color: #141312'>  </span>
<span style='color: #888786'><i>#pidgin.PurpleAccountSetAlias(my_account, "What's your name?")</i></span>
<span style='color: #888786'><i>#pidgin.PurpleAccountSetUserInfo(my_account, "Just test ")</i></span>
<span style='color: #141312'>  </span>
<span style='color: #888786'><i>#loop = gobject.MainLoop()</i></span>
<span style='color: #888786'><i>#loop.run()</i></span>

<span style='color: #888786'><i># remove \n : http://stackoverflow.com/questions/275018/how-can-i-remove-chomp-a-newline-in-python</i></span></pre></body>
</html>
